Skip to content

Conversation

@Grufoony
Copy link
Collaborator

No description provided.

@codecov
Copy link

codecov bot commented Nov 21, 2025

Codecov Report

❌ Patch coverage is 82.71605% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.34%. Comparing base (2fac69f) to head (b8a9740).
⚠️ Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
src/dsf/mobility/RoadDynamics.hpp 78.46% 14 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #370      +/-   ##
==========================================
- Coverage   83.56%   83.34%   -0.23%     
==========================================
  Files          51       52       +1     
  Lines        5216     5207       -9     
  Branches      602      593       -9     
==========================================
- Hits         4359     4340      -19     
- Misses        845      855      +10     
  Partials       12       12              
Flag Coverage Δ
unittests 83.34% <82.71%> (-0.23%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

std::optional<Id> m_nextStreetId(std::unique_ptr<Agent> const& pAgent,
Id NodeId,
std::optional<Id> streetId = std::nullopt);
std::optional<Id> m_nextStreetId(const std::unique_ptr<Agent>& pAgent,

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 12.3 rule Note

MISRA 12.3 rule
static_cast<double>(this->time_step() - pAgent->spawnTime())});
--m_nAgents;
return std::move(pAgent);
return pAgent;

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 15.5 rule Note

MISRA 15.5 rule
// Get current street information
std::optional<Id> previousNodeId = std::nullopt;
std::set<Id> forbiddenTurns;
double speedCurrent = 1.0;

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 12.3 rule Note

MISRA 12.3 rule
std::optional<Id> previousNodeId = std::nullopt;
std::set<Id> forbiddenTurns;
double speedCurrent = 1.0;
if (pAgent->streetId().has_value()) {

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 14.4 rule Note

MISRA 14.4 rule
pathTargets = it->second->path().at(pNode->id());
} catch (const std::out_of_range&) {
throw std::runtime_error(std::format("No path found for itinerary {} at node {}",
pAgent->itineraryId(),

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 12.3 rule Note

MISRA 12.3 rule
allowedTargets.insert(pathTargets.begin(), pathTargets.end());
hasItineraryConstraints = true;
for (const auto outEdgeId : outgoingEdges) {
if (forbiddenTurns.contains(outEdgeId)) {

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 14.4 rule Note

MISRA 14.4 rule
if (possibleEdgeIds.empty()) {
// Select street based on weighted probabilities
if (transitionProbabilities.empty()) {

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 14.4 rule Note

MISRA 14.4 rule
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the m_nextStreetId computation to consolidate the street selection logic into a unified probability-based approach. The changes eliminate separate code paths for random vs. non-random agents, moving several simple getter methods from .cpp files to inline implementations in headers for potential performance improvements.

  • Unified street selection algorithm using weighted probabilities for all agent types
  • Moved simple accessor methods to inline header implementations with noexcept and auto return types
  • Updated function signatures to pass node objects directly instead of node IDs

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
src/dsf/mobility/Street.hpp Added noexcept to isStochastic() virtual methods and attempted to add constexpr (incorrectly)
src/dsf/mobility/RoadJunction.hpp Converted virtual method declarations to inline implementations with attempted constexpr (incorrectly)
src/dsf/mobility/RoadJunction.cpp Removed implementations now defined inline in header
src/dsf/mobility/RoadDynamics.hpp Complete rework of m_nextStreetId to use unified probability-based selection; updated function signature; removed redundant std::move calls
src/dsf/mobility/Road.hpp Converted getter methods to inline implementations using auto return type
src/dsf/mobility/Road.cpp Removed implementations now defined inline in header
src/dsf/mobility/Agent.hpp Attempted to add constexpr to isRandom() method (incorrectly)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 501 to 507
if (outgoingEdges.size() == 1) {
auto const& pStreetOut{this->graph().edge(outgoingEdges[0])};
if (!pNode->isRoundabout() && pStreetOut->target() == pStreetOut->source()) {
return std::nullopt;
}
return outgoingEdges[0];
}
Copy link

Copilot AI Nov 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The early return for single outgoing edge bypasses important validation checks. It doesn't verify:

  1. Whether the edge is in forbiddenTurns for the current street
  2. Whether the edge is a valid path target for non-random agents with itineraries

This could lead to agents taking forbidden or invalid paths. Consider moving this check after gathering forbidden turns and path targets, or at minimum validating these conditions before the early return.

Copilot uses AI. Check for mistakes.
if (forbiddenTargetNodes.count(targetNode)) {
continue;
// Apply error probability for non-random agents
if (this->m_errorProbability.has_value() && pathTargets.empty()) {
Copy link

Copilot AI Nov 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The condition on line 563 appears incorrect. It should check !pathTargets.empty() instead of pathTargets.empty() to apply error probability only when path targets exist (i.e., for non-random agents). The current logic applies error probability when pathTargets is empty, which doesn't match the intended behavior.

Suggested change
if (this->m_errorProbability.has_value() && pathTargets.empty()) {
if (this->m_errorProbability.has_value() && !pathTargets.empty()) {

Copilot uses AI. Check for mistakes.
} catch (const std::out_of_range&) {
if (!m_itineraries.contains(pAgent->itineraryId())) {
throw std::runtime_error(
std::format("No itinerary found with id {}", pAgent->itineraryId()));

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 14.4 rule Note

MISRA 14.4 rule
// For non-random agents, get allowed targets from itinerary
std::unordered_set<Id> allowedTargets;
bool hasItineraryConstraints = false;
for (const auto outEdgeId : outgoingEdges) {

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 15.5 rule Note

MISRA 15.5 rule
if (possibleEdgeIds.size() == 1) {
return possibleEdgeIds[0];
if (transitionProbabilities.size() == 1) {
return transitionProbabilities.cbegin()->first;

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 15.5 rule Note

MISRA 15.5 rule
}
}
// Return last one as fallback
return std::prev(transitionProbabilities.cend())->first;

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 15.5 rule Note

MISRA 15.5 rule
template <typename delay_t>
requires(is_numeric_v<delay_t>)
void RoadDynamics<delay_t>::m_evolveAgents() {
if (m_agents.empty()) {

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 14.4 rule Note

MISRA 14.4 rule
@Grufoony Grufoony merged commit 7afeff6 into main Nov 22, 2025
39 of 41 checks passed
@Grufoony Grufoony deleted the reworkNextStreetId branch November 22, 2025 18:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants